package com.kube.csv;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;

public class Console {
	public static void main(String[] args) throws IOException {
		// Setup parse, and parse file
		Parser p = new CSVParser();
		Document d = p.parse(new File("c:\\restaurants.csv"));
		
		// Line read from standard in
		String input = ""; 
		System.out.println("Enter line,element (or type 'quit' to exit): ");
		InputStreamReader converter = new InputStreamReader(System.in);
		BufferedReader in = new BufferedReader(converter);
		while (!(input.equals("quit"))) {
			input = in.readLine();
			// Crudely parse input
			int l = new Integer(input.substring(0, input.indexOf(","))).intValue();
			int c = new Integer(input.substring(input.indexOf(",")+1)).intValue();
			// Get element value from document
			System.out.println("Value is: " + d.getLine(l).getElement(c).valueAsString());
		}
	}

}
